<template>
	<view>
		<u-navbar placeholder fixed autoBack border title="工人信息采集"></u-navbar>
		<view class="d-p-30">
			<view class="d-font-24 d-flex d-row-center" style="color: #ADB4BD;">
				<u--image src="/static/icon/icon-55.png" width="30rpx" height="30rpx"></u--image>
				<text class="d-m-l-10">请将采集信息输入下方框中</text>
			</view>
			<view class="d-font-32 d-m-t-30" style="font-weight: bold;color: #151C24;">合同信息</view>
			<view class="d-m-t-10">
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.sflwht = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						是否签订合同
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.sflwht_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.htlx = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						合同类型
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.htlx_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.htqdsj = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						合同签订时间
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.htqdsj_time" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.htqssj = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						合同起始时间
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.htqssj_time" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.htzzsj = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						合同终止时间
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.htzzsj_time" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						合同编号
					</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.lwhtbh" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.gzjsfs = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						工资计算方式
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.gzjsfs_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						工资标准
					</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.gzbz" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view :hidden="form.sflwht != 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.gzzfrq = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						工资支付日
					</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.gzzfrq" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input></view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
			</view>

			<view class="d-font-32 d-m-t-30" style="font-weight: bold;color: #151C24;">工资卡信息</view>
			<view class="d-m-t-10">
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.gzklb = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						工资卡类别
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.gzklb_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.gzklb != 2" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.khhyh = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						工资卡开卡银行
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.khhyh_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view :hidden="form.gzklb != 2" class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						开户行行号
					</view>
					<view class="d-flex-1"><u-input border="none" v-model="form.khhdm" inputAlign="right" placeholder="请输入"></u-input></view>
				</view>
				<view :hidden="form.gzklb != 2" class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						工资卡号
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.gzkkh" inputAlign="right" placeholder="请输入">
							<view slot="suffix" @click="camera"><u-icon name="camera" size="40rpx" color="#333"></u-icon></view>
						</u--input>
					</view>
				</view>
				<view :hidden="form.gzklb != 1" class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						社保卡号
					</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.sbkkh" type="number" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
			</view>

			<view class="d-font-32 d-m-t-30" style="font-weight: bold;color: #151C24;">其他信息</view>
			<view class="d-m-t-10">
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.sfcjjbaqpx = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						是否参加基本安全培训
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.sfcjjbaqpx_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">职称/岗位证书</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.zcgwzs" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">技能水平/等级</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.jnspdj" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.hyzk = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						婚姻状况
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.hyzk_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.zzmm = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						政治面貌
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.zzmm_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.sfjrgh = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						是否加入工会
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.sfjrgh_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view v-if="form.sfjrgh == 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.jrghsj = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						加入公会时间
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.jrghsj_time" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.sfyzdjbs = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						是否有重大疾病史
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.sfyzdjbs_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">紧急联系人</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.jjlxrxm" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">紧急联系人电话</view>
					<view class="d-flex-1"><u--input border="none" type="number" maxlength="11" v-model="form.jjlxdh" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
			</view>

			<!-- <view class="d-font-32 d-m-t-30" style="font-weight: bold;color: #151C24;">其他信息</view>
			<view class="d-m-t-10">
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.sdfl = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						户籍分类
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.sdfl_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.zzmm = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						政治面貌
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.zzmm_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.hyzk = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						婚姻状况
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.hyzk_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.whcd = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						文化程度
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.whcd_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.ksgzrq = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						开始工作时间
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.ksgzrq_time" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">紧急联系人</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.jjlxrxm" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">紧急联系人电话</view>
					<view class="d-flex-1"><u--input border="none" type="number" maxlength="11" v-model="form.jjlxdh" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.sfjrgh = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						是否加入工会
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.sfjrgh_label" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view v-if="form.sfjrgh == 1" class="d-flex u-border-bottom" style="height: 80rpx;" @click="show.jrghsj = true">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">
						<text style="color: red;">*</text>
						加入公会时间
					</view>
					<view class="d-flex-1">
						<u--input border="none" v-model="form.jrghsj_time" inputAlign="right" placeholder="请选择" disabled disabledColor="#fff"></u--input>
					</view>
					<u-icon name="arrow-down" color="#8E9291" size="28rpx"></u-icon>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">邮箱</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.cyyx" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
				<view class="d-flex u-border-bottom" style="height: 80rpx;">
					<view class="d-font-28 d-m-r-30" style="color: #5D6672;">特长</view>
					<view class="d-flex-1"><u--input border="none" v-model="form.teChang" inputAlign="right" placeholder="请输入"></u--input></view>
				</view>
			</view> -->
			<view class="d-p-80">
				<view class="d-flex d-row-center">
					<view style="width: 450rpx;"><u-button text="上一步" shape="circle" type="info" @click="back"></u-button></view>
				</view>
				<view class="d-flex d-row-center d-m-t-30">
					<view style="width: 450rpx;"><u-button text="下一步" shape="circle" type="primary" @click="addRealName4"></u-button></view>
				</view>
			</view>
		</view>
		<u-picker
			v-for="(item, index) in dict"
			:key="index"
			:show="show[index]"
			closeOnClickOverlay
			:columns="[dict[index]]"
			keyName="name"
			@close="show[index] = false"
			@cancel="show[index] = false"
			@confirm="setPicker($event, index)"
		></u-picker>

		<u-datetime-picker
			v-for="(item, index) in datePick"
			:key="index"
			:show="show[item]"
			mode="date"
			closeOnClickOverlay
			@close="show[item] = false"
			@cancel="show[item] = false"
			@confirm="setDate($event, item)"
			v-model="form[item]"
		></u-datetime-picker>

		<u-picker
			closeOnClickOverlay
			:columns="[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 226, 27, 28, 29, 30]]"
			:show="show.gzzfrq"
			@close="show.gzzfrq = false"
			@cancel="show.gzzfrq = false"
			@confirm="setGzzfrq"
		></u-picker>
	</view>
</template>

<script>
import { getDict, getOcrAuth } from '../../../common/api.js';
import { pathToBase64 } from 'image-tools';
export default {
	data() {
		return {
			maxTime: '',
			form: {
				sflwht: 1, // 是否签订合同：sflwht[字典：shifou]（默认：是）[必填]
				htlx: '', // 合同类型：htlx[字典：htlx]（根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				htqdsj: '', // 合同签订时间：htqdsj（默认当前日期，根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				htqssj: '', // 合同起始时间：htqssj（默认当前日期，根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				htzzsj: '', // 合同终止时间：htzzsj（根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				lwhtbh: '', // 合同编号：lwhtbh（根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				gzjsfs: 1, // 工资计算方式：gzjsfs[字典：jxfs]（默认：按月，根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				gzbz: '', // 工资标准：gzbz（根据“是否签订合同”字段控制，选择“是”时显示且[必填]）
				gzzfrq: '', // 工资支付日：gzzfrq（根据“是否签订合同”字段控制，选择“是”时显示且[必填]）

				gzklb: 2, // 工资卡类别：gzklb[字典：gzklb]（默认：银行卡）[必填]
				khhyh: '', // 工资卡开卡银行：khhyh[字典：jyjgbm]（根据“工资卡类别”字段控制，选择“银行卡”时显示且[必填]）
				khhdm: '', // 开户行行号：khhdm(根据工资卡开卡银行字典值进行赋值=remark字典)（根据“工资卡类别”字段控制，选择“银行卡”时显示且[必填]）
				gzkkh: '', // 工资卡号：gzkkh（根据“工资卡类别”字段控制，选择“银行卡”时显示且[必填]）
				sbkkh: '', // 社保卡号：sbkkh（根据“工资卡类别”字段控制，选择“社保卡”时显示且[必填]）

				sfcjjbaqpx: 1, // 是否参加基本安全培训 - x
				zcgwzs: '', // 职称/岗位证书 - x
				jnspdj: '', // 技能水平/等级 - x
				zzmm: '', // 政治面貌【字典】：zzmm[必填]
				hyzk: '', // 婚姻状态【字典：hyzk-cxcj】：hyzk[必填]
				sfjrgh: 0, // 是否加入工会【字典：shifou】：sfjrgh（默认值：否）[必填]
				jrghsj: '', // 加入公会时间：jrghsj（默认隐藏、加入工会选择“是”显示）
				sfyzdjbs: 0, // 是否有重大疾病史
				jjlxrxm: '', // 紧急联系人：jjlxrxm
				jjlxdh: '' // 紧急联系人电话：jjlxdh

				// sdfl: 1, // 户籍分类：sdfl[字典：hjfl][必填]
				// zzmm: '', // 政治面貌【字典】：zzmm[必填]
				// hyzk: '', // 婚姻状态【字典：hyzk-cxcj】：hyzk[必填]
				// whcd: '', // 文化程度【字典：whcd】：whcd[必填]
				// ksgzrq: '', // 开始工作时间：ksgzrq（默认当前日期，可以进行切换）
				// jjlxrxm: '', // 紧急联系人：jjlxrxm
				// jjlxdh: '', // 紧急联系人电话：jjlxdh
				// sfjrgh: 0, // 是否加入工会【字典：shifou】：sfjrgh（默认值：否）[必填]
				// jrghsj: '', // 加入公会时间：jrghsj（默认隐藏、加入工会选择“是”显示）
				// cyyx: '', // 邮箱：cyyx
				// teChang: '' // 特长：teChang
			},
			dict: {
				sflwht: [],
				htlx: [],
				gzjsfs: [],
				gzklb: [],
				khhyh: [],
				sfcjjbaqpx: [],
				'hyzk-cxcj': [],
				zzmm: [],
				sfjrgh: []
				// hjfl: [],
				// zzmm: [],
				// 'hyzk-cxcj': [],
				// whcd: [],
				// sfjrgh: []
			},
			options: {
				shifou: ['sflwht', 'sfcjjbaqpx', 'sfjrgh', 'sfyzdjbs'],
				htlx: ['htlx'],
				jxfs: ['gzjsfs'],
				gzklb: ['gzklb'],
				jyjgbm: ['khhyh'],
				'hyzk-cxcj': ['hyzk'],
				zzmm: ['zzmm']
				// hjfl: ['sdfl'],
				// zzmm: ['zzmm'],
				// 'hyzk-cxcj': ['hyzk'],
				// whcd: ['whcd'],
				// shifou: ['sfjrgh']
			},
			show: {
				sflwht: false,
				htlx: false,
				htqdsj: false,
				htqssj: false,
				htzzsj: false,
				gzjsfs: false,
				gzzfrq: false,
				gzklb: false,
				khhyh: false,
				sfcjjbaqpx: false,
				hyzk: false,
				zzmm: false,
				sfjrgh: false,
				jrghsj: false,
				sfyzdjbs: false
				// zzmm: false,
				// sdfl: false,
				// hyzk: false,
				// whcd: false,
				// sfjrgh: false,
				// jrghsj: false,
				// ksgzrq: false
			},
			datePick: ['htqdsj', 'htqssj', 'htzzsj', 'jrghsj']
			// datePick: ['jrghsj', 'ksgzrq'],
		};
	},
	onLoad() {
		this.maxTime = this.$moment().unix() * 1000;
		let names = this.options;
		for (let i in names) {
			getDict({
				name: i
			}).then(e => {
				for (let j in names[i]) {
					if (i == 'jyjgbm') {
						this.dict.khhyh = e.data.map(item => {
							return { value: item.dictValue, name: item.dictLabel, remark: item.remark };
						});
					} else {
						this.dict[names[i][j]] = e.data.map(item => {
							return { value: item.dictValue, name: item.dictLabel };
						});
					}
				}
				this.isVery();
			});
		}
		this.isVery();
	},
	onShow() {
		let form = uni.getStorageSync('store_form') || {};
		this.form = uni.$u.deepMerge(this.form, form);
		this.isVery();
	},
	methods: {
		isVery() {
			for (let i in this.datePick) {
				if (!this.form[this.datePick[i]]) {
					// 不默认
					if ('htzzsj' != this.datePick[i]) {
						this.form[this.datePick[i]] = this.$moment().format('YYYY-MM-DD');
						this.form[this.datePick[i] + '_time'] = this.$moment().format('YYYY-MM-DD');
					}
				} else {
					this.form[this.datePick[i]] = this.$moment(this.form[this.datePick[i]]).format('YYYY-MM-DD');
					this.form[this.datePick[i] + '_time'] = this.form[this.datePick[i]];
				}
			}
			let arr = [];
			for (let i in this.options) {
				for (let j in this.options[i]) {
					arr.push(this.options[i][j]);
				}
			}
			for (let i in arr) {
				if (this.dict[arr[i]]) {
					if (this.form[arr[i]] !== '') {
						// 反向渲染
						for (let j in this.dict[arr[i]]) {
							if (this.dict[arr[i]][j].value == this.form[arr[i]]) {
								this.form[arr[i] + '_label'] = this.dict[arr[i]][j].name;
								break;
							}
						}
					}
				}
			}
			this.$forceUpdate();
		},
		back() {
			uni.$u.route({
				type: 'back'
			});
		},
		addRealName4() {
			this.isVery();
			
			if (this.form.sflwht == 1) {
				if (!this.form.htlx) {
					return uni.$u.toast('请选择合同类型');
				}
				if (!this.form.htqdsj) {
					return uni.$u.toast('请选择合同签订时间');
				}
				if (!this.form.htqssj) {
					return uni.$u.toast('请选择合同起始时间');
				}
				if (!this.form.htzzsj) {
					return uni.$u.toast('请选择合同终止时间');
				}
				if (!this.form.lwhtbh) {
					return uni.$u.toast('请输入合同编号');
				}
				if (this.form.gzjsfs === '') {
					return uni.$u.toast('请选择工资计算方式');
				}
				if (!this.form.gzbz) {
					return uni.$u.toast('请输入工资标准');
				}
				if (!this.form.gzzfrq) {
					return uni.$u.toast('请选择工资支付日');
				}
			}
			if (this.form.gzklb == 2) {
				if (!this.form.khhyh) {
					return uni.$u.toast('请选择工资卡开卡银行');
				}
				if (!this.form.khhdm) {
					return uni.$u.toast('请输入开户行行号');
				}
				if (!this.form.gzkkh) {
					return uni.$u.toast('请输入工资卡号');
				}
			} else if (this.form.gzklb == 1) {
				if (!this.form.sbkkh) {
					return uni.$u.toast('请输入社保卡号');
				}
			}
			
			if (!this.form.hyzk) {
				return uni.$u.toast('请选择婚姻状况');
			}
			if (!this.form.zzmm) {
				return uni.$u.toast('请选择政治面貌');
			}
			if (this.form.sfjrgh && !this.form.jrghsj) {
				return uni.$u.toast('请选择加入工会时间');
			}
			
			// if (!this.form.whcd) {
			// 	return uni.$u.toast('请选择文化程度');
			// }
			// if (!this.form.sdfl) {
			// 	return uni.$u.toast('请选择户籍分类');
			// }
			// if (!this.form.ksgzrq) {
			// 	return uni.$u.toast('请选择开始工作时间');
			// }
			uni.setStorageSync('store_form', this.form);
			uni.$u.route({
				url: '/pages/index/member/addRealName4'
			});
		},
		setDate(e, name) {
			this.show[name] = false;
			if (e.value) {
				this.form[name] = this.$moment(e.value).format('YYYY-MM-DD');
				this.form[name + '_time'] = this.$moment(e.value).format('YYYY-MM-DD');
			} else {
				this.form[name] = this.$moment(new Date()).format('YYYY-MM-DD');
				this.form[name + '_time'] = this.$moment(new Date()).format('YYYY-MM-DD');
			}
		},
		setPicker(e, name) {
			this.show[name] = false;
			if (name != 'hyzk-cxcj') {
				this.form[name] = e.value[0].value;
				this.form[name + '_label'] = e.value[0].name;
			} else {
				if (name == 'hyzk-cxcj') {
					this.form.hyzk = e.value[0].value;
					this.form.hyzk_label = e.value[0].name;
				}
			}
			if (name == 'khhyh') {
				this.form.khhdm = e.value[0].remark;
			}
		},
		setGzzfrq(e) {
			this.form.gzzfrq = e.value[0];
			this.show.gzzfrq = false;
		},
		camera() {
			uni.chooseImage({
				count: 1,
				sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
				sourceType: ['album', 'camera'], //从相册选择
				success: res => {
					uni.showLoading({ title: '图片格式转换中' });
					this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
						this.getOCRsignature(base64);
					});
				}
			});
		},
		imgToBase64(data) {
			return new Promise((resolve, reject) => {
				pathToBase64(data)
					.then(base64 => {
						resolve(base64);
					})
					.catch(error => {
						console.error(error);
						reject(error);
					});
			});
		},
		getOCRsignature(ImageBase64) {
			const _this = this;
			getOcrAuth(
				{
					ImageBase64
				},
				{
					custom: {
						noToken: true
					}
				}
			).then(res => {
				uni.showLoading({ title: '卡号提取中' });
				uni.request({
					url: 'https://ocr.tencentcloudapi.com',
					method: 'POST',
					data: {
						ImageBase64: ImageBase64
					},
					header: {
						'X-TC-Action': 'BankCardOCR',
						'X-TC-Version': '2018-11-19',
						'X-TC-Region': 'ap-beijing',
						'X-TC-Timestamp': res.timestamp,
						'Content-Type': 'application/json; charset=utf-8',
						Authorization: res.data
					},
					success: e => {
						uni.hideLoading();
						if (e.data.Response.Error) {
							uni.$u.toast(e.data.Response.Error.Message);
						} else {
							const result = e.data.Response;
							_this.form.gzkkh = result.CardNo;
						}
					},
					fail: e => {
						uni.hideLoading();
						uni.$u.toast('卡号提取失败');
					}
				});
			});
		}
	}
};
</script>

<style lang="scss"></style>
